﻿using MediatR;
using NPOI.SS.Formula.Functions;
using Warehouse.API.Applcation.Command.MovelibraryCommand;
using Warehouse.Infrstructre.Interface;

namespace Warehouse.API.Applcation.CommandHandlers.MovelibraryCommandHandlers
{
    /// <summary>
    /// 审核
    /// </summary>
    public class MovelibraryAuditCommandHandler:IRequestHandler<MovelibraryAuditCommand,int>
    {
        private readonly IMovelibraryRepository _movelibraryRep;

        public MovelibraryAuditCommandHandler(IMovelibraryRepository movelibraryRep)
        {
            _movelibraryRep = movelibraryRep;
        }

        public async Task<int> Handle(MovelibraryAuditCommand request, CancellationToken cancellationToken)
        {
            var list = await _movelibraryRep.GetModelAsync(request.MovelibraryId);
            list.DocumentStatus = request.DocumentStatus;
            list.ReasonForReview = request.ReasonForReview;
            list.AddName = request.AddName;
            list.AddTime = request.AddTime;
            list.UpdName = "呓语";
            list.UpdTime = request.UpdTime;
            return await _movelibraryRep.UpdateAsync(list);
        }
    }
}
